package com.JL.test;

import com.JL.engine.View.AnimationChannel;
import com.JL.engine.View.RectView;
import com.JL.engine.model.Component;
import com.sun.org.apache.bcel.internal.generic.NEW;

import java.awt.*;

public class MoveComponent extends Component {
    private AnimationChannel<String> ac = new AnimationChannel<>();

    @Override
    public void onAdded() {
        RectView rectView = new RectView(0,this.entity.getWidth(),this.entity.getHeight(), Color.RED,true);
        RectView lu = new RectView(1,10,10,20,20,Color.BLACK,true);
        RectView ru = new RectView(1,this.entity.getWidth() - 30,10,20,20,Color.BLACK,true);
        RectView ld = new RectView(1,10,this.entity.getHeight() - 30,20,20,Color.BLACK,true);
        RectView rd = new RectView(1,this.entity.getWidth() - 30,this.entity.getHeight() - 30,20,20,Color.BLACK,true);
        this.entity.addView(rectView);
        this.entity.addView(lu);
        this.entity.addView(ru);
        this.entity.addView(ld);
        this.entity.addView(rd);
    }

    public void moveUp(int distance) {
        this.entity.setTranslation(0,-distance);

    }

    public void moveDown(int distance) {
        this.entity.setTranslation(0,distance);

    }

    public void moveLeft(int distance) {
        this.entity.setTranslation(-distance,0);

    }

    public void moveRight(int distance) {
        this.entity.setTranslation(distance,0);

    }

}
